package com.xinfu.newproject.presenter;

import com.xinfu.newproject.bean.community.ExistCommunityBean;
import com.xinfu.newproject.bean.community.ExistCommunityBody;
import com.xinfu.newproject.callback.MyCallBack;
import com.xinfu.newproject.model.community.ExistCommunityModel;
import com.xinfu.newproject.view.IView;

import io.reactivex.disposables.Disposable;

public class ExistCommunityPresenter {
    private IView.IExistCommunityView mIExistCommunityView;

    private ExistCommunityModel mExistCommunityModel;

    public ExistCommunityPresenter(IView.IExistCommunityView iExistCommunityView) {
        this.mIExistCommunityView = iExistCommunityView;
        mExistCommunityModel = new ExistCommunityModel();
    }

    /**
     * 获取已绑定房产
     */
    public void existCommunity() {

        mIExistCommunityView.showProgress();

        ExistCommunityBody existCommunityBody = new ExistCommunityBody(mIExistCommunityView.header(), mIExistCommunityView.userId(), mIExistCommunityView.auditRes());

        mExistCommunityModel.existCommunity(existCommunityBody, new MyCallBack<ExistCommunityBean>() {
            @Override
            public void onSuccess(ExistCommunityBean existCommunityBean) {
                mIExistCommunityView.hideProgress();

                if (existCommunityBean.isSuccess()) {
                    mIExistCommunityView.getData(existCommunityBean);
                } else {
                    mIExistCommunityView.showToast(existCommunityBean.getMessage());
                }

            }

            @Override
            public void onError(String header, String message) {
                mIExistCommunityView.hideProgress();
                mIExistCommunityView.showToast(message);
            }

            @Override
            public void onDispose(Disposable disposable) {
                mIExistCommunityView.closeDispose(disposable);
            }
        });


    }


//    private Map<String, String> createParaMap() {
//        Map<String, String> paraMap = new HashMap<>();
//        paraMap.put("userName", mIRegisterView.getUserName());
//        return paraMap;
//    }

}
